
<%@page import="study.itwill.team5.board.BoardItem"%>
<%@page import="java.util.ArrayList"%>
<%@page import="study.itwill.team5.board.Board"%>
<%@page import="study.itwill.common.PatternChecker"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%
	String seq = request.getParameter("seq");

	if (!PatternChecker.isValue(seq)) {
		out.print("<script type='text/javascript'>alert('파라미터가 없습니다.');history.back();</script>");
		return;
	}
	if (!PatternChecker.isNum(seq)) {
		out.print("<script type='text/javascript'>alert('파라미터가 부정확합니다.');history.back();</script>");
		return;
	}

	int board_number = Integer.parseInt(seq);
%>

<%@ include file="../dbcon.jsp"%>
<%
	Board board = new Board();
    ArrayList<BoardItem> list_board = board.listBoard(0);
    int n_category_seq = -1;
    for (int i=0; i<list_board.size(); i++) {
	BoardItem item = list_board.get(i);
	if (item.getSeq() == board_number) {
		n_category_seq = item.getBoard_category_seq();
	}
}
	boolean result = board.deleteBoard(board_number);

	DBHandler.disconnect();

	if (!result) {
		out.print("<script type='text/javascript'>alert('삭제에 실패했습니다..');history.back();</script>");
		return;
	}
	// 삭제 성공시 목록으로 이동
	response.sendRedirect("listBoard.jsp?category="+board_number);
	 
%> 